//
//  ContactManager.m
//  04-字典
//
//  Created by mafeng on 16/7/7.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "ContactManager.h"

@implementation ContactManager
- (instancetype)initWithDictionary:(NSMutableDictionary *)contactDictionary {
    self = [super init];
    if (self) {
        _contactDictionary = contactDictionary;
    }
    return self;
}
- (void)addContact:(Contact *)contact {
    if (contact.name.length > 0 && contact.phoneNumber.length > 0) {
        NSMutableArray *array = [_contactDictionary objectForKey:contact.groupName];
        if (array == nil) {
            array = [NSMutableArray arrayWithObjects:contact];
            [_contactDictionary setObject:array forKey:contact.groupName];
        } else {
            [array addObject:contact];
        }
        NSLog(@"添加联系人成功");
    } else {
        NSLog(@"添加联系人失败");
    }
    
}
- (void)removeContact:(Contact *)contact {
    
}
- (void)removeGroupWithGrounpName:(NSString *)groupName {
    [_contactDictionary removeObjectForKey:groupName];
}
@end
